<template>
  <smart-page>
    <template #actions>

      <a-button type="primary" @click="onScanApp()">扫描可执行程序</a-button>
    </template>
    <template #search>
      <smart-search :query-array="APP_SEARCH" @on-handler="onSearch"/>
    </template>
    <a-table v-model:selectedKeys="selectedKeys"
             :table-layout-fixed="theme.layoutFixed"
             :row-selection="rowSelection"
             :columns="APP_COLUMNS"
             :row-key="rowKey"
             :column-resizable="theme.resizable"
             :bordered="theme.bordered"
             :stripe="theme.stripe"
             :sticky-header="theme.sticky"
             :hoverable="theme.hoverAble"
             :pagination="pagination"
             :loading="theme.loading"
             :data="dataSource"
             @page-change="onPageChange"
             @page-size-change="onPageSizeChange" />
  </smart-page>
</template>
<script lang="ts" setup name="system-schedule-app">
import {onMounted} from 'vue';

import {APP_SEARCH} from '../resource/search'
import {APP_COLUMNS} from "../resource/colums";
import {TablePage} from "@/libs/core";
import {SystemHttp} from "../resource/http";
import {MsgUtil} from "@/utils";
import {Acl} from "@/libs/acl";


const pageConfig = {title: '登陆日志', rowKey: 'id', nameKey: 'name'}
const {getScheduleAppPage, scanApp} = SystemHttp
const tablePage = new TablePage(pageConfig).setFetchXhr(getScheduleAppPage).setPermission(Acl.SYSTEM_SCHEDULE_APP_PAGE_LIST);

const {theme, pagination, rowKey, dataSource, rowSelection, selectedKeys, editCtr} = tablePage
const {onFetch, onPageChange, onPageSizeChange, onDelete, onSearch} = tablePage
onMounted(() => onFetch())


const onScanApp = () => {
  const handler = async () => {
    const {message} = await scanApp()
    MsgUtil.notify("操作成功", message)
    await onFetch()
  }
  MsgUtil.confirm(`确定要重新扫描系统可执行的应用程序吗?`, handler)
}
</script>

